const std = @import("std");

threadlocal var thread_name: [30]u8 = std.mem.zeroes([30]u8);

pub fn setThreadName(name: []const u8) !void {
    if (name.len > 30) {
        return error.IceLengthTooBig;
    }
    @memset(&thread_name, 0);
    for (0..name.len) |i| {
        thread_name[i] = name[i];
    }
}

pub fn getThreadName() []const u8 {
    if (thread_name[0] == 0) {
        return "unknown";
    }
    return thread_name[0..];
}

pub fn getThreadId() u64 {
    return @intCast(std.Thread.getCurrentId());
}
